<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录</title>
    <link rel="stylesheet" href="./html/css/login.css">
    <style>.one-pan-tip {
            cursor: pointer;
        }

        .one-pan-tip::before {
            background-position: center;
            background-size: 100% 100%;
            background-repeat: no-repeat;
            box-sizing: border-box;
            width: 1em;
            height: 1em;
            margin: 0 1px .15em 1px;
            vertical-align: middle;
            display: inline-block;
        }

        .one-pan-tip-success::before {
            content: '';
            background-image: url()
        }

        .one-pan-tip-error {
            text-decoration: line-through;
        }

        .one-pan-tip-error::before {
            content: '';
            background-image: url()
        }

        .one-pan-tip-other::before {
            content: '';
            background-image: url()
        }

        .one-pan-tip-lock::before {
            content: '';
            background-image: url()
        }</style>
    <meta name="ljjc::status" content="on">
</head>

<body>
<div class="login">
    <div class="center">
        <div class="main">
            <div class="title"></div>
            <div class="inputLi">
                <input type="text" class="user" autofocus="autofocus" title="账户" placeholder="请输入账户" required=""
                       v-model="username">
            </div>
            <div class="inputLi">
                <input type="password" class="pwd" title="密码" placeholder="请输入密码" required="" v-model="password">
            </div>

            <div class="button-group">
                <button @click="login()">登录</button>
            </div>
        </div>
    </div>
</div>
<script src="//apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
</script>
<script src="//cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script type="text/javascript">
    document.onmousedown = function () {
        if (event.button == 2) {
            alert("禁止复制,请前去下载");
            return false;
        }
    }
</script>
<script>

    var vm = new Vue({
        el: ".login",
        data: {
            cimg: "",
            username: "",
            password: "",
        },
        created: function () {


        },
        methods: {
            refresh_pic() {
                // alert("验证码已经刷新");
                this.username_ready();
            },
            login() {
                $.ajax({
                    //请求方式
                    type: "POST",
                    //请求地址
                    url: "/logproc",
                    //数据，json字符串
                    data: {
                        "username": this.username,
                        "password": this.password,
                    },
                    dataType: "json",
                    //请求成功
                    success: function (ret) {
                        if (ret.code == 0) {
                            alert(ret.data.message);
                            $.ajax({
                                //请求方式
                                type: "POST",
                                //请求地址
                                url: "/writelogin",
                                //数据，json字符串
                                data: {
                                    "username": ret.data.username,
                                    "token": ret.data.token,
                                },
                                success: function (ret) {
                                    alert("登录成功，正在转向控制面板");
                                    window.location = "/";
                                }
                            });
                        } else if (ret.code == -105) {
                            window.open("http://app.bilihp.com:81/geetest.html" + ret.data.substring(ret.data.indexOf("?"), ret.data.length) + "&username=" + vm.username, "_blank");
                        } else if (ret.code == 201) {
                            window.open(ret.data.url, "_blank");
                            // window.location = ret.data.url
                        } else {
                            alert(ret.data);
                        }
                    },
                    //请求失败，包含具体的错误信息
                    error: function (e, msg, ds) {
                        // console.log(ds);
                        // console.log(msg);
                        // console.log(e.responseText);
                    }
                });


            },
        }
    })

</script>


</body>
</html>